<template>
	<view v-if="state.list.length">
		<view class="u-flex u-flex-between u-p-l-30 u-p-t-30 u-font-27">
			<text class="u-content-color">抽奖预告</text>
		</view>
		<view class="lucky-card u-flex u-bg-white u-p-20 u-m-30 u-radius-8" v-for="(item,index) in state.list" :key="index" @click="toDetail(item.id)">
			<up-image :show-loading="true" :src="item.cover" width="60px" height="60px"></up-image>
			<view class="u-m-l-20 u-font-26">
				<p class="u-font-30">{{item.name}}</p>
				<p class="u-m-t-5 u-content-color">开始时间：{{timeFormat(item.start, 'mm月dd日 hh时MM分ss秒')}}</p>
			</view>
		</view>
		<up-gap height="10" bgColor="#fafafa"></up-gap>
	</view>
</template>

<script setup>
	import { timeFormat } from '@/uni_modules/uview-plus';
	import {
		onLoad,
		onShow
	} from '@dcloudio/uni-app'
	import {
		onMounted,
		reactive,
		nextTick,
		computed,
		ref
	} from 'vue';
	import {
		BASE_URL,
		REQUEST_SUCCESS
	} from '/utils/config.js';
	import createApi from '/api/commonAPI.js';
	const commonAPI = createApi(store);
	import {
		useAuth
	} from '/composables/useAuth';
	import {
		useCommon
	} from '/composables/useCommon.js';
	import {
		useStore
	} from 'vuex';
	const store = useStore();
	// 计算属性，用于获取 Vuex 中的状态
	const {
		qiniuDomain,
	} = useCommon();
	const {
		token,
		user_id,
		userInfo,
		hasAuth,
		SET_SIGN,
		hasSigned,
		SET_NOT_LOGIN,
		getUserAccount
	} = useAuth();
	const state = reactive({
		list: [],
	})
	onMounted(() => {
		// 获取抽奖历史
		commonAPI.luckPreview().then(res => {
			if (res.code == REQUEST_SUCCESS) {
				state.list = res.data.data
			}
		})
	})
	const toDetail = (id) =>{
		uni.navigateTo({
			url:'../../pages/history/luckDetail?id=' + id
		})
	}
</script>

<style lang="scss" scoped>

</style>